package com.senyin.service.impl;


import com.senyin.common.BaseResponse;
import com.senyin.common.ErrorCode;
import com.senyin.common.ResultUtils;
import com.senyin.dao.PositionDao;
import com.senyin.entity.Position;
import com.senyin.service.PositionService;
import org.apache.commons.lang3.StringUtils;

import javax.servlet.http.HttpServletRequest;
import java.sql.SQLException;
import java.util.List;
import java.util.Objects;

public class PositionServiceImpl implements PositionService {
    private PositionDao positionDao = new PositionDao();

    @Override
    public BaseResponse<List<Position>> showAll() throws SQLException {
        return positionDao.showAll();
    }

    @Override
    public BaseResponse addPosition(Position position, HttpServletRequest request) throws SQLException {
        if (Objects.isNull(position)||Objects.isNull(request)){
            return ResultUtils.error(ErrorCode.NULL_ERROR,"请求为空");
        }
        return positionDao.addPosition(position,request);
    }

    @Override
    public BaseResponse modPosition(Position position, HttpServletRequest request) throws SQLException {
        if (Objects.isNull(position)||Objects.isNull(request)){
            return ResultUtils.error(ErrorCode.NULL_ERROR,"请求为空");
        }
        return positionDao.modPosition(position,request);
    }

    @Override
    public BaseResponse delPositionByUUID(String UUID, HttpServletRequest request) throws SQLException {
        if (StringUtils.isAnyBlank(UUID) ||Objects.isNull(request)){
            return ResultUtils.error(ErrorCode.NULL_ERROR,"请求为空");
        }
        return positionDao.delPositionByUUID(UUID,request);
    }
}




